<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <h1>登录页面</h1>
    <form>
        <input type="text" id="phone" placeholder="请输入你的手机号">
        <input type="password" id="password" placeholder="请输入你的密码">
        <input type="button" id="" value="提交" onclick="RegisterFunction()">
    </form>
    <script>
        function RegisterFunction() {
            var phone = document.getElementById("phone").value
            var password = document.getElementById("password").value
            var xmlhttp;

            if (window.XMLHttpRequest) {

                // IE7+, Firefox, Chrome ,Opera, Safari 浏览器执行代码
                xmlhttp = new XMLHttpRequest();
            } else {

                //IE6, IE5 浏览器执行代码
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }

            xmlhttp.onreadystatechange = function() {

                if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {

                    // console.log(xmlhttp.responseText)
                    console.log(xmlhttp.responseText);
                    // document.getElementById("myDiv").innerHTML = xmlhttp.responseText;
                    var result = JSON.parse(xmlhttp.responseText);

                    if (result.status == 1) {
                        alert("登录成功");
                    } else {
                        alert(result.errorMsg);
                    };

                };
            };

            xmlhttp.open("POST", "http://192.168.59.139:5010/login", true);

            xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

            xmlhttp.send("phone=" + phone + "&pass_word=" + password);

        }
    </script>
</body>

</html>